﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TPTecnicas.MessageProcessor.Business
{
    public class AcademicPeriod
    {
        List<Period> periods;

        public AcademicPeriod()
        {
            periods = new List<Period>();

            Period primerCuat = new Period();
            primerCuat.name = "1erCuat ";
            primerCuat.startDay = 1;
            primerCuat.startMonth = 1;
            primerCuat.endDay = 30;
            primerCuat.endMonth = 6;
            periods.Add(primerCuat);

            Period segundoCuat = new Period();
            segundoCuat.name = "2doCuat ";
            segundoCuat.startDay = 1;
            segundoCuat.startMonth = 7;
            segundoCuat.endDay = 31;
            segundoCuat.endMonth = 12;
            periods.Add(segundoCuat);

        }

        public AcademicPeriod(List<Period> periods)
        {
            this.periods = periods;
        }

        //se deben cargar los periodos lectivos
        public void addPeriod(Period p){
            periods.Add(p);
        }
        public string getCurrentPeriod() {
                     
            foreach (Period p in periods){
                DateTime periodStart = new DateTime(DateTime.Now.Year, p.startMonth, p.startDay);
                DateTime periodEnd = new DateTime(DateTime.Now.Year, p.endMonth, p.endDay);

                if((periodStart < DateTime.Now) && (DateTime.Now < periodEnd) ){
                    return p.name + DateTime.Now.Year.ToString();
                }
            }
            return "Periodo Invalido ";
        }
    }
}